﻿#region Copyleft and Copyright

// .NET Dev Tools Dashboard
// Copyright 2011 (C) Wim Van den Broeck - Techno-Fly
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Wim Van den Broeck (wim@techno-fly.net)

#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Techno_Fly.Tools.Dashboard
{
    /// <summary>
    /// Carries the payload for a composite event, and also allows an action to be cancelled.
    /// </summary>
    /// <typeparam name="TPayload">The type of the payload.</typeparam>
    public class CancelableEventArgs<TPayload>
    {
        bool _cancel;
        /// <summary>
        /// Gets or sets a value indicating whether the action should be cancelled.
        /// </summary>
        /// <value><c>true</c> if cancel; otherwise, <c>false</c>.</value>
        public bool Cancel
        {
            get
            {
                return _cancel;
            }
            set
            {
                if (!value) /* We do not allow the value to be set to false 
							 * because it may hide another handlers intent. [DV] */
                {
                    return;
                }
                _cancel = true;
            }
        }

        /// <summary>
        /// Gets or sets the payload used by the action.
        /// </summary>
        /// <value>The payload.</value>
        public TPayload Payload { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="CancelableEventArgs{TPayload}"/> class,
        /// using the specified payload. Can be <code>null</code>.
        /// </summary>
        /// <param name="payload">The payload. Can be null.</param>
        public CancelableEventArgs(TPayload payload)
        {
            Payload = payload;
        }

    }
}